#!/bin/bash
read -p "please input username prefix:" user
read -p "please input numbers of users:" num
for i in $(seq -w $num)
do
	id ${user}$i &>/dev/null
	if (( $? != 0 ));then
		useradd ${user}$i && echo "${user}${i} has been cread"
		read -s -p "please input password of users:" u_pwd
		if [[ -n $u_pwd ]] && [[ -z $u_pwd ]];then
			echo "the password not null"
		else 
			echo "${u_pwd}" |passwd ${user}$i --stdin &>/dev/null && echo "${user}$i has been sets password"
		fi	 
	else
		echo "${user}$i already exist"
	fi
done
